
/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes')

var querystring = require("querystring"), fs = require("fs"), Client = require('mysql').Client;
var Client = require('mysql').Client;
var mysql = require('mysql');
var client = new Client(); 
	client.user = 'root';
	client.password = '';
	client.host="127.0.0.1";
	//client.port="3306";
	client.database="famAlbum"


var app = module.exports = express.createServer();
//var searchFile = require("./public/javascripts/search.js");

// Configuration

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

app.configure('development', function(){
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
});

app.configure('production', function(){
  app.use(express.errorHandler()); 
});

app.dynamicHelpers({
	page: function() {
    	return {};
  	},
  	
	script: function(req, res){
    	req._scripts = [];
    	return function(path){
    	  req._scripts.push(path);
    	}
    
	},

	scripts: function(req, res){
	    return req._scripts;
	},
	
	css: function(req, res){
    	req._css = [];
    	return function(path){
    	  req._css.push(path);
    	}
    
	},

	csss: function(req, res){
	    return req._css;
	}

})


// Requestes are routed to their respective hanlers 


app.get('/', routes.main.main);
app.get('/detail/:gebaeude?', routes.detail.getDetails);
app.get('/image/:id?', routes.detail.getImage);


app.listen(4321);
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
